{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Original sample: [60 84 64 59 58 30  1 97 58 34]\n",
      "Sample mean: 54.5\n",
      "Number of bootstrap re-samples: 100\n",
      "Example re-sample: [30 59 97 58 60 84 58 34 64 58]\n",
      "Mean of re-samples' means: 54.183\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "# Sample 10 integers\n",
    "sample = np.random.randint(low=1, high=100, size=10)\n",
    "print('Original sample: %s' % sample)\n",
    "print('Sample mean: %s' % sample.mean())\n",
    "\n",
    "# Bootstrap re-sample 100 times by re-sampling with replacement from the original sample\n",
    "resamples = [np.random.choice(sample, size=sample.shape) for i in range(100)]\n",
    "print('Number of bootstrap re-samples: %s' % len(resamples))\n",
    "print('Example re-sample: %s' % resamples[0])\n",
    "\n",
    "resample_means = np.array([resample.mean() for resample in resamples])\n",
    "print('Mean of re-samples\\' means: %s' % resample_means.mean())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
